package org.example.demo;

import org.example.demo.bean.Recipe;
import org.example.demo.service.Assistant;
import org.example.demo.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ChatController {


    @Autowired
    Assistant assistant;
    @Autowired
    DocumentService documentService;

    @GetMapping("/chat")
    public String chat(String message) {
        return assistant.chat(message);
    }

    @GetMapping("/chatHis")
    public String chatWithHistory(String id, String message) {
        return assistant.chatWithHistory(id, message);
    }

    @GetMapping("/recipe")
    public Recipe recipe(String dishType, String ingredients) {
        return assistant.createRecipeAsObject(dishType, ingredients);
    }

    @GetMapping("/loadDocument")
    public List<String> loadDocument() {
         return documentService.loadSplitAndEmbed();
    }

    @GetMapping("/search")
    public List<String> search(String query) {
         return documentService.search(query);
    }
}
